package com.example.pages;

import java.util.List;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

public class InternalPage extends AnyPage {
	
	@FindBy(css = "nav li > a")
	public List <WebElement> menuLinks;
	
	public void goToProfilePage() {
		menuLinks.get(1).click();
	}
	
	public ManagementPage goToManagementPage() {
		menuLinks.get(2).click();
		return MyPageFactory.getPage(driver, ManagementPage.class);
	}
	
	public void goToHomePage() {
		menuLinks.get(0).click();
	}
	
	public void logout() {
		menuLinks.get(menuLinks.size() - 1).click();
		wait_().until(alertIsPresent()).accept();
	}
	
	public boolean isOnThisPage() {
		return menuLinks.get(0).isDisplayed();
	}
	
	@Override
	void tryToOpen() {
		MyPageFactory.getPage(driver, LoginPage.class).loginAs("admin", "admin");
	}
}
